﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SAI
{
    class PuzzleState
    {
        int[][] _state;
        int _dimension;
        /*
        PuzzleState _right;
        PuzzleState _left;
        PuzzleState _down;
        PuzzleState _up;
        */
        int[] _zeroInd;

        public PuzzleState(int[][] state)
        {
            _state = state;
            _dimension = _state.Length;
            _zeroInd = new int[2];
            bool found = false;
            for (int i = 0; !found && i < state.Length; i++)
            {
                for (int j = 0; !found && j < state[i].Length; j++ )
                {
                    if (state[i][j] == 0)
                    {
                        _zeroInd[0] = i;
                        _zeroInd[1] = j;
                        found = true;
                    }
                }
            }
        }

        public int[][] State { get { return _state; } }
        public int Dimension { get { return _dimension; } }
        public int[] ZeroInd { get { return _zeroInd; } }
        /*
        public PuzzleState Right { get { return _right; } set { _right = value; } }
        public PuzzleState Down { get { return _down; } set { _down = value; } }
        public PuzzleState Up { get { return _up; } set { _up = value; } }
        public PuzzleState Left { get { return _left; } set { _left = value; } }
        */
        public bool compare(PuzzleState other)
        {
            int[][] otherState = other.State;
            for (int i = 0; i < _state.Length; i++)
            {
                if (otherState[i] != _state[i])
                    return false;
            }
            return true;
        }
       
        public void printState()
        {
            Console.WriteLine("-----------------------------------");
            for (int i = 0; i < _dimension; i++)
            {
                for (int j = 0; j < _dimension; j++)
                    Console.Write(_state[i][j] + " ");
                Console.WriteLine();
            }
            Console.WriteLine("-----------------------------------\n");
        }
        
    }
}
